<?php

class Adept_Controller_Lifecycle /* extends Adept_Controller_Base */ {
  
  const TEMPLATE = 'tpl';
  
  public function process() {
      
    $request = Adept_Context::getInstance()->getRequest();
    
    if (!$request->hasParameter(self::TEMPLATE)) {
      throw new Adept_Exception("Parameter " . self::TEMPLATE . " not defiend in request");
    }
    
    $tpl = $request->getParameter(self::TEMPLATE);
    
    $template = new Adept_Template_ComponentTree($tpl);
    
    Adept_Context::getInstance()->setRoot($template->getRoot());
    
    $lifecycle = Adept_Lifecycle::getInstance();
    $lifecycle->execute();
    $lifecycle->render();  	
    
  }
  
}